package com.snake.mylibrary.loader;

import com.snake.mylibrary.net.HttpStatus;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**动态结果*/
public abstract class DynamicResult {
	
	private HttpStatus err;//网络状态
	public DynamicResult(JSONObject jo, HttpStatus err)
	{
		this.err = err;
		if(err == HttpStatus.HTTP_OK && jo != null)
		{
			parserOriginalData(jo);//解析数据
		}
	}
	
	public HttpStatus getErr() {
		return err;
	}
	
	public void setErr(HttpStatus status)
	{
		err = status;
	}
	
	public Map<HttpStatus, String> getErrText()
	{
		return new HashMap<>();
	}
	
	public abstract boolean isDataValid();
	
	protected abstract void parserOriginalData(JSONObject obj);
}
